package com.meishij.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.meishij.R;
import com.meishij.entry.MallCategoryEntry;

import java.util.List;

/**
 * Created by 肖荣 on 2016/10/13.
 */

public class MallCategoryDetailAdapter extends RecyclerView.Adapter<MallCategoryDetailAdapter.ViewHolder> {
    private Context context;
    private List<MallCategoryEntry.GoodsListBean> goodsListBeenList;

    public MallCategoryDetailAdapter(Context context, List<MallCategoryEntry.GoodsListBean> goodsListBeenList) {
        this.context = context;
        this.goodsListBeenList = goodsListBeenList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_mall_end_list_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.mall_end_list_item_image.setImageURI(goodsListBeenList.get(position).getImage());
        holder.mall_end_list_item_title.setText(goodsListBeenList.get(position).getTitle());
        holder.mall_end_list_item_price.setText("¥"+goodsListBeenList.get(position).getPrice());
        holder.mall_end_list_item_market_price.setText("¥"+goodsListBeenList.get(position).getMarket_price());
        holder.mall_end_list_item_market_price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    }

    @Override
    public int getItemCount() {
        return goodsListBeenList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{

        private SimpleDraweeView mall_end_list_item_image;
        private TextView mall_end_list_item_title;
        private TextView mall_end_list_item_price;
        private TextView mall_end_list_item_market_price;

        public ViewHolder(View itemView) {
            super(itemView);
            mall_end_list_item_image = ((SimpleDraweeView) itemView.findViewById(R.id.mall_end_list_item_image));
            mall_end_list_item_title = ((TextView) itemView.findViewById(R.id.mall_end_list_item_title));
            mall_end_list_item_price = ((TextView) itemView.findViewById(R.id.mall_end_list_item_price));
            mall_end_list_item_market_price = ((TextView) itemView.findViewById(R.id.mall_end_list_item_market_price));
        }
    }
}
